home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1996 July / EnigmA AMIGA RUN 09 (1996)(G.R. Edizioni)(IT)[!][issue 1996-07 & 08][EARSAN CD VIII].iso / earcd / dev1 / energy.lha / Energy / C2E / MUI / Balancing.e next >
Text File  |  1996-05-18  |  5KB  |  168 lines

  1. OPT OSVERSION=37
  2. OPT PREPROCESS
  3.  
  4. MODULE    'libraries/mui',
  5.     'muimaster',
  6.     'dos/dos',
  7.     'intuition/classes',
  8.     'intuition/classusr',
  9.     'utility/hooks',
  10.     'utility/tagitem'
  11.  
  12. #define MAKE_ID(a,b,c,d) ( Shl(a,24) OR Shl(b,16) OR Shl(c,8) OR d )
  13.  
  14. PROC main()
  15.  
  16. DEF    app,window,sigs = 0
  17.  
  18.  
  19. IF muimasterbase := OpenLibrary('muimaster.library',MUIMASTER_VMIN)
  20.  
  21.  
  22.     app := ApplicationObject,
  23.         MUIA_Application_Title      , 'BalanceDemo',
  24.         MUIA_Application_Version    , '$VER: BalanceDemo 12.10 (21.11.95)',
  25.         MUIA_Application_Copyright  , '©1995, Stefan Stuntz',
  26.         MUIA_Application_Author     , 'Stefan Stuntz',
  27.         MUIA_Application_Description, 'Show balancing groups',
  28.         MUIA_Application_Base       , 'BALANCEDEMO',
  29.  
  30.         SubWindow, window := WindowObject,
  31.             MUIA_Window_Title, 'Balancing Groups',
  32.             MUIA_Window_ID   , MAKE_ID("B","A","L","A"),
  33.             MUIA_Window_Width , MUIV_Window_Width_Screen(50),
  34.             MUIA_Window_Height, MUIV_Window_Height_Screen(50),
  35.  
  36.             WindowContents, HGroup,
  37.  
  38.                 Child, VGroup, GroupFrame, MUIA_Weight, 15,
  39.                     Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  40.                     Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  41.                     Child, BalanceObject, End,
  42.                     Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  43.                     End,
  44.  
  45.                 Child, BalanceObject, End,
  46.  
  47.                 Child, VGroup,
  48.                     Child, HGroup, GroupFrame,
  49.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 123, End,
  50.                         Child, BalanceObject, End,
  51.                         Child, RectangleObject, TextFrame, MUIA_ObjectID, 456, End,
  52.                         End,
  53.                     Child, HGroup, GroupFrame,
  54.                         Child, RectangleObject, TextFrame, End,
  55.                         Child, BalanceObject, End,
  56.                         Child, RectangleObject, TextFrame, End,
  57.                         Child, BalanceObject, End,
  58.                         Child, RectangleObject, TextFrame, End,
  59.                         Child, BalanceObject, End,
  60.                         Child, RectangleObject, TextFrame, End,
  61.                         Child, BalanceObject, End,
  62.                         Child, RectangleObject, TextFrame, End,
  63.                         End,
  64.                     Child, HGroup, GroupFrame,
  65.                         Child, HGroup,
  66.                             Child, RectangleObject, TextFrame, End,
  67.                             Child, BalanceObject, End,
  68.                             Child, RectangleObject, TextFrame, End,
  69.                             End,
  70.                         Child, BalanceObject, End,
  71.                         Child, HGroup,
  72.                             Child, RectangleObject, TextFrame, End,
  73.                             Child, BalanceObject, End,
  74.                             Child, RectangleObject, TextFrame, End,
  75.                             End,
  76.                         End,
  77.                     Child, HGroup, GroupFrame,
  78.                         Child, RectangleObject, TextFrame, MUIA_Weight,  50, End,
  79.                         Child, RectangleObject, TextFrame, MUIA_Weight, 100, End,
  80.                         Child, BalanceObject, End,
  81.                         Child, RectangleObject, TextFrame, MUIA_Weight, 200, End,
  82.                         End,
  83.                     Child, HGroup, GroupFrame,
  84.                         Child, SimpleButton('Also'),
  85.                         Child, BalanceObject, End,
  86.                         Child, SimpleButton('Try'),
  87.                         Child, BalanceObject, End,
  88.                         Child, SimpleButton('Sizing'),
  89.                         Child, BalanceObject, End,
  90.                         Child, SimpleButton('With'),
  91.                         Child, BalanceObject, End,
  92.                         Child, SimpleButton('Shift'),
  93.                         End,
  94.                     End,
  95.                 End,
  96.             End,
  97.  
  98.         End
  99.  
  100.     IF app=NIL THEN fail(app,'Failed to create Application.')
  101.  
  102.     doMethod(window,[MUIM_Notify,MUIA_Window_CloseRequest,MUI_TRUE,
  103.         app,2,MUIM_Application_ReturnID,MUIV_Application_ReturnID_Quit])
  104.  
  105.  
  106. /*
  107. ** This is the ideal input loop for an object oriented MUI application.
  108. ** Everything is encapsulated in classes, no return ids need to be used,
  109. ** we just check if the program shall terminate.
  110. ** Note that MUIM_Application_NewInput expects sigs to contain the result
  111. ** from Wait() (or 0). This makes the input loop significantly faster.
  112. */
  113.  
  114.     set(window,MUIA_Window_Open,TRUE)
  115.  
  116.         WHILE doMethod(app,[MUIM_Application_NewInput,{sigs}]) <> MUIV_Application_ReturnID_Quit
  117.  
  118.             IF sigs
  119.                 sigs := Wait(sigs OR SIGBREAKF_CTRL_C)
  120.                 IF (sigs AND SIGBREAKF_CTRL_C)
  121.                     set(window,MUIA_Window_Open,FALSE)
  122.                     fail(app,NIL)
  123.                 ENDIF
  124.             ENDIF
  125.         ENDWHILE
  126.  
  127.     set(window,MUIA_Window_Open,FALSE)
  128.  
  129.  
  130. /*
  131. ** Shut down...
  132. */
  133.  
  134.     fail(app,NIL)
  135. ENDIF
  136. ENDPROC
  137.  
  138. PROC fail(app,str)
  139.  
  140.  IF app THEN Mui_DisposeObject(app)
  141.  
  142.  IF muimasterbase THEN CloseLibrary(muimasterbase)
  143.  
  144.     IF str
  145.       WriteF(str)
  146.       CleanUp(20)
  147.     ENDIF
  148.  
  149. ENDPROC
  150.  
  151. PROC doMethod( obj:PTR TO object, msg:PTR TO msg )
  152.  
  153.     DEF h:PTR TO hook, o:PTR TO object, dispatcher
  154.  
  155.     IF obj
  156.         o := obj-SIZEOF object    /* instance data is to negative offset */
  157.         h := o.class
  158.         dispatcher := h.entry    /* get dispatcher from hook in iclass */
  159.         MOVEA.L h,A0
  160.         MOVEA.L msg,A1
  161.         MOVEA.L obj,A2        /* probably should use CallHookPkt, but the */
  162.         MOVEA.L dispatcher,A3    /*   original code (DoMethodA()) doesn't. */
  163.         JSR (A3)        /* call classDispatcher() */
  164.         MOVE.L D0,o
  165.         RETURN o
  166.     ENDIF
  167. ENDPROC NIL
  168.